package com.bridge.utils;

/**
 * @author bridge
 * @Date 2022/07/10/22:33
 */
public class ResUtils<T> {

    private int code;

    private String msg;

    private T data;

    public static ResUtils<String> error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static ResUtils<String> error(int code, String msg) {
        ResUtils<String> r = new ResUtils<>();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public static <T> ResUtils<T> ok(String msg, T data) {
        ResUtils<T> r = new ResUtils<>();
        r.setCode(200);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static <T> ResUtils<T> ok( T data) {
        ResUtils<T> r = new ResUtils<>();
        r.setCode(200);
        r.setData(data);
        return r;
    }

    public static <T> ResUtils<T> ok() {
        ResUtils<T> r = new ResUtils<>();
        r.setCode(200);
        return r;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
